#include <Box2D.h>
#include "common.h"
#include "b2DistanceJointDef.h"

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT void JNICALL Java_b2DistanceJointDef_jni_1b2DistanceJointDef_1GetLocalPoint
  (JNIEnv *env, jclass cls, jint localAnchorA, jint bodyA, jint anchorA, jint localAnchorB, jint bodyB, jint anchorB)
{
	b2Vec2* localAnchor = (b2Vec2*)localAnchorA;
	b2Body* body = (b2Body*)bodyA;
	b2Vec2* anchor = (b2Vec2*)anchorA;

	*localAnchor = body->GetLocalPoint(*anchor);


	localAnchor = (b2Vec2*)localAnchorB;
	body = (b2Body*)bodyB;
	anchor = (b2Vec2*)anchorB;

	*localAnchor = body->GetLocalPoint(*anchor);
}


JNIEXPORT jfloat JNICALL Java_b2DistanceJointDef_jni_1b2DistanceJointDef_1length
  (JNIEnv *env, jclass cls, jint v1, jint v2)
{
	b2Vec2 *bv1 = (b2Vec2*)v1;
	b2Vec2 *bv2 = (b2Vec2*)v2;

	b2Vec2 v = (*bv2) - (*bv1);
	return v.Length();
}

#ifdef __cplusplus
}
#endif
